/*
 * @Author: long-xinyu2 2192763423@qq.com
 * @Date: 2025-04-01 10:09:57
 * @LastEditors: long-xinyu2 2192763423@qq.com
 * @LastEditTime: 2025-05-08 16:56:59
 * @FilePath: \algorithm\algorithm-training\lqb\acwing4_1.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include<iostream>
#include<cstring>
#include<vector>
#include<map>
#include<cstdio>
#include<algorithm>
#include<string>
#include<string.h>
#include<queue>
#include<math.h>
#include<set>
#include<functional>
#include <bitset>
using namespace std;
using ull = unsigned long long;
using i128 = __int128_t;
//inline int inc(int x,int v,int mod){x+=v;return x>=mod?x-mod:x;}//代替取模+
#define endl '\n'
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;



struct Node
{
    char a;
    int ax;
    char b;
};



void solve()
{
    int n;
    cin >> n;
    vector<int>arr(n + 10);
    int cnt = 0;
    for(int i = 1; i <= n; i ++)
    {
        cin >> arr[i];
    }
    map<int,int>mp;
    vector<int>res(n + 10);
    for(int i = n; i >= 1; i --)
    {
        mp[arr[i]] ++;
        res[i] = mp[arr[i]];
    }
    if(mp.size() == 1)
    {
        cout << n << endl;
        return;
    }
    int ans = 0;
    int flag = n;
    mp.clear();
    while(1)
    {
        for(int i = 1; i <= flag; i ++)
        {
            res[i] -= mp[arr[i]];
            if(res[i] == 1)
            {
                mp.clear();
                for(int j = i; j <= flag; j ++)
                {
                    mp[arr[j]] ++;
                }
                ans ++;
                flag = i - 1;
                break;
            }
        }
        if(flag == 0) break;
    }
    cout << ans << endl;
}
int main()
{
    int t = 1;
    //cin >> t;
    while(t --)
    {
        solve();
    }
}